import Cookies from 'js-cookie';

export function setUserCookie(userInfo) {
  const arr = Object.entries(userInfo);
  for (let index = 0; index < arr.length; index += 1) {
    Cookies.set(arr[index][0], arr[index][1]);
  }
}

export function getUserCookie() {
  return {
    username: Cookies.get('username'),
    appkey: Cookies.get('appkey'),
    email: Cookies.get('email'),
    role: Cookies.get('role'),
  };
}

export function removeUserCookie() {
  Cookies.remove('username');
  Cookies.remove('role');
  Cookies.remove('email');
  Cookies.remove('appkey');
}
